﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Acms.AcmsControls;

public partial class Templates_MediaNumberedGallery_Default : Acms.AcmsControls.DummyTemplatePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        pager.DataBinding += new EventHandler(pager_DataBinding);
        pager.DataBound += new EventHandler(pager_DataBound);
        dlItems.DataBinding += new EventHandler(dlItems_DataBinding);
        dlItems.ItemDataBound += new EventHandler<Acms.WebControls.AcmsDataListItemEventArgs>(dlItems_ItemDataBound);
        if (!IsPostBack)
        {
            DataBind();
        }
    }

    void pager_DataBound(object sender, EventArgs e)
    {
        if (pager.Items.Length == 0 || pager.Items.Length == 1)
        {
            pager.Visible = false;
        }
    }

    void dlItems_ItemDataBound(object sender, Acms.WebControls.AcmsDataListItemEventArgs e)
    {
        if (e.Item.IsDataItem)
        {
            e.Item.CssClass = e.Item.ItemIndex == 0 ? "galleryItem" : "galleryItemHidden";
        }
    }

    void pager_DataBinding(object sender, EventArgs e)
    {
        pager.DataSource = AcmsContext.CurrentPost.Children;
    }

    void dlItems_DataBinding(object sender, EventArgs e)
    {
        dlItems.DataSource = AcmsContext.CurrentPost.Children;
    }
}
